<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>生存战争服务端安装向导</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', system-ui, sans-serif;
        }
        
        body {
            background: #f0f2f5;
            color: #333;
            min-height: 100vh;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        
        .container {
            width: 100%;
            max-width: 800px;
            background: white;
            border-radius: 8px;
            overflow: hidden;
            box-shadow: 0 5px 25px rgba(0, 0, 0, 0.1);
            margin: 20px;
        }
        
        .header {
            background: #2c3e50;
            color: white;
            padding: 15px 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        }
        
        .header h1 {
            font-size: 18px;
            font-weight: 600;
        }
        
        .header .step-indicator {
            font-size: 14px;
            opacity: 0.8;
        }
        
        .content {
            padding: 0;
        }
        
        .section {
            display: none;
            padding: 20px;
        }
        
        .section.active {
            display: block;
        }
        
        .section-title {
            font-size: 20px;
            font-weight: 600;
            margin-bottom: 15px;
            color: #2c3e50;
            display: flex;
            align-items: center;
            padding-bottom: 10px;
            border-bottom: 1px solid #eee;
        }
        
        .section-title i {
            margin-right: 10px;
            font-size: 22px;
            color: #3498db;
        }
        
        .section-content {
            margin-top: 15px;
            line-height: 1.6;
            color: #444;
        }
        
        .card {
            background: #f8f9fa;
            border-radius: 6px;
            padding: 15px;
            margin: 15px 0;
            border-left: 4px solid #3498db;
        }
        
        .card-warning {
            border-left-color: #f39c12;
            background: #fef9e7;
        }
        
        .card-success {
            border-left-color: #27ae60;
            background: #eafaf1;
        }
        
        .card-danger {
            border-left-color: #e74c3c;
            background: #fdedec;
        }
        
        .btn-group {
            display: flex;
            gap: 10px;
            margin-top: 20px;
            flex-wrap: wrap;
        }
        
        .btn {
            padding: 10px 20px;
            font-size: 14px;
            border: none;
            border-radius: 6px;
            cursor: pointer;
            transition: all 0.3s ease;
            font-weight: 500;
            display: inline-flex;
            align-items: center;
            justify-content: center;
        }
        
        .btn-primary {
            background: #3498db;
            color: white;
        }
        
        .btn-primary:hover {
            background: #2980b9;
        }
        
        .btn-secondary {
            background: #95a5a6;
            color: white;
        }
        
        .btn-success {
            background: #27ae60;
            color: white;
        }
        
        .btn-warning {
            background: #f39c12;
            color: white;
        }
        
        .btn-danger {
            background: #e74c3c;
            color: white;
        }
        
        .btn i {
            margin-right: 8px;
            font-size: 14px;
        }
        
        .progress-container {
            width: 100%;
            height: 10px;
            background: #e0e0e0;
            border-radius: 10px;
            margin: 15px 0;
            overflow: hidden;
        }
        
        .progress-bar {
            height: 100%;
            background: #3498db;
            width: 0%;
            border-radius: 10px;
            transition: width 0.4s ease;
        }
        
        .progress-info {
            display: flex;
            justify-content: space-between;
            margin-top: 8px;
            font-size: 12px;
            color: #7f8c8d;
        }
        
        .status {
            display: inline-flex;
            align-items: center;
            padding: 5px 10px;
            background: #ecf0f1;
            border-radius: 50px;
            font-size: 12px;
            margin: 8px 0;
        }
        
        .status i {
            margin-right: 5px;
        }
        
        .status-success {
            background: #eafaf1;
            color: #27ae60;
        }
        
        .status-warning {
            background: #fef9e7;
            color: #f39c12;
        }
        
        .status-error {
            background: #fdedec;
            color: #e74c3c;
        }
        
        .qq-code {
            text-align: center;
            margin: 15px 0;
            font-size: 22px;
            color: #3498db;
            font-weight: 700;
            background: #f8f9fa;
            padding: 12px;
            border-radius: 6px;
        }
        
        .file-select {
            padding: 12px;
            border: 2px dashed #e0e0e0;
            border-radius: 6px;
            text-align: center;
            margin: 15px 0;
            transition: all 0.3s;
            cursor: pointer;
        }
        
        .file-select:hover {
            border-color: #3498db;
            background: #f8fcff;
        }
        
        .user-type {
            display: flex;
            gap: 15px;
            margin-top: 15px;
        }
        
        .user-option {
            flex: 1;
            background: #f8f9fa;
            border-radius: 6px;
            padding: 15px;
            text-align: center;
            cursor: pointer;
            transition: all 0.3s;
            border: 2px solid transparent;
        }
        
        .user-option:hover {
            border-color: #3498db;
        }
        
        .user-option.selected {
            border-color: #3498db;
            background: #e3f2fd;
        }
        
        .user-option h3 {
            margin: 12px 0 8px;
            color: #2c3e50;
            font-size: 16px;
        }
        
        .user-option p {
            font-size: 13px;
            color: #7f8c8d;
        }
        
        .user-option i {
            font-size: 36px;
            color: #3498db;
        }
        
        .footer {
            text-align: center;
            color: #7f8c8d;
            font-size: 11px;
            padding: 15px;
            border-top: 1px solid #eee;
        }
        
        .step-content {
            min-height: 350px;
        }
        
        .compact-list {
            margin: 10px 0;
            padding-left: 20px;
        }
        
        .compact-list li {
            margin-bottom: 8px;
            font-size: 14px;
        }
        
        .path-display {
            font-family: monospace;
            background: #f8f9fa;
            padding: 8px 12px;
            border-radius: 4px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            font-size: 13px;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="header">
            <h1><i class="fas fa-server"></i> 生存战争服务端安装向导</h1>
            <div class="step-indicator">步骤 <span id="current-step">1</span>/7</div>
        </div>
        
        <div class="content">
            <!-- 步骤1：开始页面 -->
            <div class="section active" id="step1">
                <div class="section-title">
                    <i class="fas fa-user"></i> 选择您的用户类型
                </div>
                
                <div class="section-content">
                    <p>按照自己的情况选择</p>
                    
                    <div class="card card-warning">
                        <div style="display: flex; align-items: center;">
                            <i class="fas fa-exclamation-circle" style="font-size: 20px; margin-right: 10px; color: #f39c12;"></i>
                            <div style="font-size: 14px;">
                                <strong>重要提示：</strong> 开服需要了解IP、端口、网络等基本概念。
                            </div>
                        </div>
                    </div>
                    
                    <div class="user-type">
                        <div class="user-option" onclick="selectUserType('beginner')">
                            <i class="fas fa-seedling"></i>
                            <h3>新手玩家</h3>
                            <p>不知道IP、端口等网络概念</p>
                        </div>
                        
                        <div class="user-option" onclick="selectUserType('advanced')">
                            <i class="fas fa-dragon"></i>
                            <h3>老手玩家</h3>
                            <p>了解网络概念，有开服经验</p>
                        </div>
                    </div>
                </div>
            </div>
            
            <!-- 步骤2：运行库检查 -->
            <div class="section" id="step2">
                <div class="section-title">
                    <i class="fas fa-code"></i> 检查运行库状态
                </div>
                
                <div class="section-content">
                    <p>生存战争服务端需要 <strong>.NET Framework 4.7.2</strong> 运行环境支持</p>
                    
                    <div class="card">
                        <div class="status status-warning" id="dotnet-status">
                            <i class="fas fa-sync-alt fa-spin"></i> 正在检测 .NET Framework 4.7.2...
                        </div>
                        
                        <div style="margin-top: 15px;">
                            <div style="display: flex; align-items: center; margin-bottom: 10px;">
                                <div style="flex: 1; font-size: 14px;">运行库状态:</div>
                                <div class="status status-warning" id="dotnet-result">
                                    <i class="fas fa-hourglass-half"></i> 检查中...
                                </div>
                            </div>
                            
                            <div style="display: flex; align-items: center; margin-bottom: 10px;">
                                <div style="flex: 1; font-size: 14px;">Windows版本:</div>
                                <div id="windows-version">检测中...</div>
                            </div>
                            
                            <div style="display: flex; align-items: center;">
                                <div style="flex: 1; font-size: 14px;">系统架构:</div>
                                <div id="system-arch">检测中...</div>
                            </div>
                        </div>
                    </div>
                </div>
            </极速赛车开奖官网
            <!-- 步骤3：下载运行库 -->
            <div class="section" id="step3">
                <div class="section-title">
                    <i class="fas fa-download"></i> 下载运行库安装程序
                </div>
                
                <div class="section-content">
                    <p>您的系统缺少必要的组件，需要下载约68MB的安装程序</p>
                    
                    <div class="card card-warning">
                        <h3 style="margin-bottom: 10px; color: #2c3e50; font-size: 16px;">
                            <i class="fas fa-exclamation-triangle" style="color: #f39c12;"></i> 系统需求提醒
                        </h3>
                        <ul class="compact-list">
                            <li>如有问题请以管理员身份运行此向导</li>
                            <li>确保有良好的网络连接</li>
                            <li>至少预留200 MB的空间给服务端</li>
                        </ul>
                    </div>
                    
                    <div style="margin: 15px 0;">
                        <div class="progress-container">
                            <div class="progress-bar" id="download-progress"></div>
                        </div>
                        <div class="progress-info">
                            <span>进度: <span id="download-percent">0%</span></span>
                            <span>速度: <span id="download-speed">0 KB/s</span></span>
                            <span>剩余: <span id="download-time">未知</span></span>
                        </div>
                    </div>
                    
                    <button class="btn btn-primary" id="btn-download" onclick="startDownload()">
                        <i class="fas fa-download"></i> 开始下载
                    </button>
                </div>
            </div>
            
            <!-- 步骤4：加入QQ群 -->
            <div class="section" id="step4">
                <div class="section-title">
                    <i class="fas fa-users"></i> 获取服务端文件
                </div>
                
                <div class="section-content">
                    <p>由于服务端不公开提供，您需要加入官方QQ群获取</p>
                    
                    <div class="qq-code">
                        <i class="fab fa-qq"></i> QQ群: 893387376
                    </div>
                    
                    <div class="card">
                        <h3 style="margin-bottom: 10px; color: #2c3e50; font-size: 16px;">
                            <i class="fas fa-sign-in-alt" style="color: #3498db;"></i> 加入群聊后的步骤
                        </h3>
                        
                        <ul class="compact-list">
                            <li><strong>下载群文件:</strong> 查找"Sc服务器开服端"文件夹,在里面找最新的版本</li>
                            <li><strong>阅读教程:</strong> 在群文件中找到名字是"服务端使用教程"文件夹</li>
                            <li><strong>有问题?:</strong> 遇到问题可在群里询问管理员</li>
                        </ul>
                        
                        <div class="card card-danger" style="margin-top: 15px;">
                            <div style="font-size: 14px;">
                                <i class="fas fa-exclamation-circle"></i> <strong>注意：</strong> 
                                非QQ用户需要自行解决
                            </div>
                            <div style="margin-top: 8px; color: #e74c3c; font-size: 13px;">
                                联系我备用网站链接：https://chat.jiil.top (注册后加好友JIIL)
                            </div>
                        </div>
                    </div>
                    
                    <button class="btn btn-primary" onclick="nextStep()">
                        <i class="fas fa-forward"></i> 已获取服务端，继续安装
                    </button>
                </div>
            </div>
            
            <!-- 步骤5：安装服务端 -->
            <div class="section" id="step5">
                <div class="section-title">
                    <i class="fas fa-folder-plus"></i> 安装服务端程序
                </div>
                
                <div class="section-content">
                    <p>请选择已下载的服务端ZIP文件和解压位置</p>
                    
                    <div class="file-select" id="file-drop-area" onclick="document.getElementById('server-file').click()">
                        <p style="font-size: 50px; color: #3498db; margin-bottom: 10px;">
                            <i class="fas fa-file-archive"></i>
                        </p>
                        <h3 style="margin-bottom: 8px; font-size: 16px;">点击选择服务端ZIP文件</h3>
                        <p style="color: #7f8c8d; margin-bottom: 15px; font-size: 13px;">或拖放文件到此处</p>
                    </div>
                    <input type="file" id="server-file" accept=".zip" style="display: none" onchange="handleFileSelect()">
                    <p id="file-info" style="text-align: center; font-style: italic; color: #7f8c8d; margin-bottom: 15px; font-size: 极速赛车开奖官网
                        尚未选择文件
                    </p>
                    
                    <div class="card">
                        <h3 style="margin-bottom: 10px; color: #2c3e50; font-size: 16px;">
                            <i class="fas fa-exclamation-triangle" style="color: #f39c12;"></i> 解压位置
                        </h3>
                        
                        <div style="margin-top: 10px;">
                            <div style="display: flex; align-items: center; margin-bottom: 10px;">
                                <div style="flex: 1; font-size: 14px;">安装路径:</div>
                                <div class="path-display" id="install-path">
                                    正在获取默认路径...
                                </div>
                            </div>
                            
                            <div style="color: #7f8c8d; font-size: 13px; margin-top: 8px;">
                                <i class="fas fa-info-circle"></i> 不选择默认安装在文档目录
                            </div>
                        </div>
                        
                        <button class="btn btn-secondary" style="margin-top: 15px; padding: 8px 15px;" onclick="changeInstallPath()">
                            <i class="fas fa-exchange-alt"></i> 更改安装位置
                        </button>
                    </div>
                    
                    <button class="btn btn-primary" id="btn-install" onclick="installServer()">
                        <i class="fas fa-play"></i> 开始安装服务端
                    </button>
                </div>
            </div>
            
            <!-- 步骤6：账号配置 -->
            <div class="section" id="step6">
                <div class="section-title">
                    <i class="fas fa-user-cog"></i> 账号配置
                </div>
                
                <div class="section-content">
                    <p>需要配置社区账号和获取服务器权限</p>
                    
                    <div class="card">
                        <div style="text-align: center; padding: 20px;">
                            <div style="font-size: 40px; color: #3498db; margin-bottom: 15px;">
                                <i class="fas fa-user-circle"></i>
                            </div>
                            <h3 style="margin-bottom: 8px; color: #2c3e50; font-size: 16px;">您有社区账号吗？</h3>
                            <p style="color: #7f8c8d; margin-bottom: 15px; font-size: 13px;">
                                社区链接: <a href="https://www.schub.top" target="_blank">https://www.schub.top</a>
                            </p>
                            
                            <div class="btn-group" style="justify-content: center;">
                                <button class="btn btn-success" onclick="hasCommunityAccount(true)" style="padding: 8px 15px;">
                                    <i class="fas fa-check"></i> 有社区账号
                                </button>
                                <button class="btn btn-danger" onclick="hasCommunityAccount(false)" style="padding: 8px 15px;">
                                    <i class="fas fa-times"></i> 没有账号
                                </button>
                            </div>
                        </div>
                    </div>
                    
                    <div class="card card-warning" id="account-warning" style="display: none;">
                        <h3 style="margin-bottom: 10px; color: #2c3e50; font-size: 16px;">
                            <i class="fas fa-exclamation-triangle" style="color: #f39c12;"></i> 注意
                        </h3>
                        <p id="warning-text" style="font-size: 14px;">
                            拥有社区账号还不够！您需要获得服主认证。<br>
                            在QQ群893387376中艾特群主申请服主身份，并提供您的注册邮箱。
                        </p>
                        
                        <button class="btn btn-secondary" style="margin-top: 10px; padding: 8px 15px;" onclick="document.getElementById('account-warning').style.display = 'none'">
                            <i class="fas fa-check-circle"></i> 我已知悉
                        </button>
                    </div>
                    
                    <button class="btn btn-primary" onclick="nextStep()" style="margin-top: 10px;">
                        <i class="fas fa-forward"></i> 我已配置好账号
                    </button>
                </div>
            </div>
            
            <!-- 步骤7：完成安装 -->
            <div class="section" id="step7">
                <div class="section-title">
                    <i class="fas fa-flag-checkered"></i> 安装完成
                </div>
                
                <div class="section-content">
                    <div class="card card-success">
                        <div style="text-align: center; padding: 20px;">
                            <div style="font-size: 50px; color: #27ae60; margin-bottom: 15px;">
                                <i class="fas fa-check-circle"></i>
                            </div>
                            <h2 style="margin-bottom: 10px; color: #2c3e50; font-size: 20px;">恭喜您完成安装！</h2>
                            <p style="font-size: 14px; color: #555;">
                                生存战争服务端已成功安装并配置完成
                            </p>
                            
                            <div style="background: #eafaf1; border-radius: 6px; padding: 15px; margin: 20px 0;">
                                <p style="font-size: 14px;">
                                    <strong>服务端路径:</strong> <span id="final-path">C:\Users\YourName\Documents\SurvivalWarServer</span>
                                </p>
                            </div>
                        </div>
                    </div>
                    
                    <h3 style="margin: 15px 0 10px; color: #2c3e50; font-size: 16px;">
                        <i class="fas fa-play-circle"></i> 如何启动服务器
                    </h3>
                    
                    <ul class="compact-list">
                        <li>打开服务端文件夹（点击下方按钮）</li>
                        <li>找到 <code>TerminalEntry.exe</code> 文件</li>
                        <li>双击运行（不要运行其他可执行文件）</li>
                        <li>首次启动会初始化并生成必要文件</li>
                        <li>根据服务端使用教程进行操作还有配置公网</li>
                        <li>如果遇到问题，请礼貌询问,也可使用JCM服务端管理工具来进行问题排查</li>
                    </ul>
                    
                    <div class="btn-group">
                        <button class="btn btn-success" onclick="openServerFolder()" style="padding: 10px 15px;">
                            <i class="fas fa-folder-open"></i> 打开服务端文件夹
                        </button>
                        <button class="btn btn-primary" onclick="window.open('https://chat.jiil.top/jcm/rm.php', '_blank')" style="padding: 10px 15px;">
                            <i class="fas fa-download"></i> 
                        </button>
                    </div>
                    
                    <div style="margin-top: 15px;">
                        <p style="color: #7f8c8d; font-size: 13px;">
                            更多帮助信息可在之前加入的QQ群内获取,下载JCM服务端管理工具帮助你更快理解
                        </p>
                    </div>
                </div>
            </div>
        </div>
        
        <div class="footer">
            JIIL Studio 开发 | JCM套件工具 v1 | JSUpdate
        </div>
    </div>

    <script>
        // 步骤管理
        let currentStep = 1;
        let totalSteps = 7;
        let dotnetInstalled = false;
        let installPath = "";
        
        function updateStepIndicator() {
            document.getElementById('current-step').textContent = currentStep;
        }
        
        function nextStep() {
            if(currentStep >= totalSteps) return;
            
            // 隐藏当前步骤
            document.getElementById(`step${currentStep}`).classList.remove('active');
            
            // 显示下一步
            currentStep++;
            document.getElementById(`step${currentStep}`).classList.add('active');
            
            updateStepIndicator();
            
            // 特殊处理
            if(currentStep === 2) {
                checkDotNet();
            }
        }
        
        function prevStep() {
            if(currentStep <= 1) return;
            
            // 隐藏当前步骤
            document.getElementById(`step${currentStep}`).classList.remove('active');
            
            // 显示上一步
            currentStep--;
            document.getElementById(`step${currentStep}`).classList.add('active');
            
            updateStepIndicator();
        }
        
        // 选择用户类型
        function selectUserType(type) {
            if(type === 'beginner') {
                alert('作为新手玩家，我们建议您先了解IP、端口、网络协议等基本概念后再继续开服。');
                if(confirm('您确定要现在退出并学习相关知识吗？')) {
                    document.querySelector('.container').innerHTML = `
                        <div class="header">
                            <h1><i class="fas fa-server"></i> 生存战争服务端安装向导</h1>
                        </div>
                        <div class="content" style="text-align: center; padding: 40px 20px;">
                            <div style="font-size: 60px; color: #3498db; margin-bottom: 20px;">
                                <i class="fas fa-book"></i>
                            </div>
                            <h2 style="margin: 15px 0 10px; font-size: 20px;">祝您学习愉快！</h2>
                            <p style="color: #7f8c8d; font-size: 14px; margin-bottom: 20px;">
                                准备好开服后，请再次运行本安装向导继续。
                            </p>
                            <button class="btn btn-primary" onclick="location.reload()" style="padding: 10px 20px;">
                                <i class="fas fa-redo"></i> 重新开始
                            </button>
                        </div>
                    `;
                    return;
                }
            } else {
                // 继续到下一步
                nextStep();
            }
        }
        
        // 检查.NET运行库
        function checkDotNet() {
            const status = document.getElementById('dotnet-status');
            const result = document.getElementById('dotnet-result');
            const windowsVersion = document.getElementById('windows-version');
            const systemArch = document.getElementById('system-arch');
            
            // 调用后端API检查.NET运行库
            fetch('/check_dotnet')
                .then(response => response.json())
                .then(data => {
                    if(data.status === 'success') {
                        // 获取Windows版本信息
                        windowsVersion.textContent = data.windows_version;
                        systemArch.textContent = data.system_arch;
                        
                        if(data.has_dotnet) {
                            status.innerHTML = '<i class="fas fa-check-circle" style="color: #27ae60;"></i> 检测完成';
                            result.innerHTML = '<i class="fas fa-check-circle" style="color: #27ae60;"></i> 已安装 .NET Framework 4.7.2';
                            result.className = 'status status-success';
                            
                            // 自动跳过下载步骤
                            setTimeout(() => {
                                // 直接进入第4步（跳过下载）
                                currentStep = 3; // 设置当前步骤为3（下载步骤是3）
                                nextStep(); // 进入第4步
                            }, 1500);
                        } else {
                            status.innerHTML = '<i class="fas fa-exclamation-triangle" style="color: #e74c3c;"></i> 检测完成';
                            result.innerHTML = '<i class="fas fa-times-circle" style="color: #e74c3c;"></i> 未安装 .NET Framework 4.7.2';
                            result.className = 'status status-error';
                            
                            // 显示下载提示
                            setTimeout(() => {
                                nextStep();
                            }, 1500);
                        }
                    } else {
                        status.innerHTML = '<i class="fas fa-exclamation-triangle" style="color: #e74c3c;"></i> 检测失败';
                        result.innerHTML = '<i class="fas fa-times-circle" style="color: #e74c3c;"></i> ' + data.message;
                        result.className = 'status status-error';
                    }
                })
                .catch(error => {
                    status.innerHTML = '<i class="fas fa-exclamation-triangle" style="color: #e74c3c;"></i> 检测失败';
                    result.innerHTML = '<i class="fas fa-times-circle" style="color: #e74c3c;"></i> ' + error.message;
                    result.className = 'status status-error';
                });
        }
        
        // 开始下载运行库
        function startDownload() {
            const btn = document.getElementById('btn-download');
            btn.disabled = true;
            btn.innerHTML = `<i class="fas fa-sync fa-spin"></i> 下载中...`;
            
            const progressBar = document.getElementById('download-progress');
            const percent = document.getElementById('download-percent');
            const speed = document.getElementById('download-speed');
            const time = document.getElementById('download-time');
            
            // 调用后端API开始下载
            fetch('/download_dotnet')
                .then(response => {
                    const reader = response.body.getReader();
                    const contentLength = response.headers.get('Content-Length');
                    let receivedLength = 0;
                    
                    // 读取流数据
                    function read() {
                        return reader.read().then(({ done, value }) => {
                            if (done) {
                                // 下载完成
                                btn.innerHTML = `<i class="fas fa-check"></i> 下载完成`;
                                
                                // 自动进入下一步
                                setTimeout(nextStep, 1000);
                                return;
                            }
                            
                            receivedLength += value.length;
                            const progress = Math.floor((receivedLength / contentLength) * 100);
                            
                            // 更新进度条
                            progressBar.style.width = progress + '%';
                            percent.textContent = progress + '%';
                            
                            // 继续读取
                            return read();
                        });
                    }
                    
                    return read();
                })
                .catch(error => {
                    btn.innerHTML = `<i class="fas fa-exclamation-triangle"></i> 下载失败`;
                    console.error('下载失败:', error);
                });
        }
        
        // 处理文件选择
        function handleFileSelect() {
            const fileInput = document.getElementById('server-file');
            const fileInfo = document.getElementById('file-info');
            const installBtn = document.getElementById('btn-install');
            
            if(fileInput.files.length > 0) {
                const file = fileInput.files[0];
                fileInfo.innerHTML = `
                    <i class="fas fa-check-circle" style="color: #27ae60;"></i>
                    已选择文件: <b>${file.name}</b>
                    <br>
                    大小: ${Math.round(file.size / (1024 * 1024))} MB
                `;
                installBtn.disabled = false;
            } else {
                fileInfo.innerHTML = '尚未选择文件';
                installBtn.disabled = true;
            }
        }
        
        // 更改安装路径
        function changeInstallPath() {
            // 调用后端API打开文件夹选择对话框
            fetch('/choose_install_path')
                .then(response => response.json())
                .then(data => {
                    if(data.status === 'success') {
                        installPath = data.path;
                        document.getElementById('install-path').textContent = installPath;
                    } else if(data.status === 'cancel') {
                        // 用户取消选择
                        console.log("用户取消选择安装路径");
                    } else {
                        alert("选择路径失败: " + data.message);
                    }
                })
                .catch(error => {
                    alert("请求失败: " + error.message);
                });
        }
        
        // 安装服务端
        function installServer() {
            const btn = document.getElementById('btn-install');
            btn.disabled = true;
            btn.innerHTML = `<i class="fas fa-sync fa-spin"></i> 安装中...`;
            
            const fileInput = document.getElementById('server-file');
            const file = fileInput.files[0];
            
            // 获取安装路径
            const pathDisplay = document.getElementById('install-path').textContent;
            
            // 调用后端API安装服务端
            const formData = new FormData();
            formData.append('file', file);
            formData.append('path', pathDisplay);
            
            fetch('/install_server', {
                method: 'POST',
                body: formData
            })
            .then(response => response.json())
            .then(data => {
                if(data.status === 'success') {
                    btn.innerHTML = `<i class="fas fa-check"></i> 安装成功`;
                    
                    // 更新最终路径显示
                    document.getElementById('final-path').textContent = data.install_path;
                    
                    // 进入下一步
                    setTimeout(nextStep, 1000);
                } else {
                    btn.innerHTML = `<i class="fas fa-exclamation-triangle"></i> 安装失败`;
                    alert('安装失败: ' + data.message);
                }
            })
            .catch(error => {
                btn.innerHTML = `<i class="fas fa-exclamation-triangle"></i> 安装失败`;
                console.error('安装失败:', error);
            });
        }
        
        // 社区账号处理
        function hasCommunityAccount(hasAccount) {
            const warning = document.getElementById('account-warning');
            const warningText = document.getElementById('warning-text');
            
            if(hasAccount) {
                warningText.innerHTML = `
                    拥有社区账号还不够！您需要获得服主认证。<br>
                    在QQ群893387376中 <strong>@群主</strong> 申请服主身份，并提供您的注册邮箱。
                    <div style="margin-top: 10px; padding: 8px; background: #fef9e7; border-radius: 4px; font-size: 13px;">
                        处理时间：未知
                    </div>
                `;
            } else {
                warningText.innerHTML = `
                    <strong>当前临时注册通道：</strong>
                    <div style="margin: 8px 0; padding: 8px; background: #fdedec; border-radius: 4px; font-size: 13px;">
                        <i class="fas fa-link"></i> https://screg.zzwei.net
                    </div>
                    此链接为临时注册通道，不会一直开放。<br>
                    您也可以定期访问社区网站 <a href="https://www.schub.top" target="_blank">https://www.schub.top</a> 查看最新注册情况。
                    <div style="margin-top: 10px; padding: 8px; background: #fef9e7; border-radius: 4px; font-size: 13px;">
                        <i class="fas fa-comment-alt"></i> 或者在QQ群893387376中询问最新注册方式
                    </div>
                `;
            }
            
            // 显示警告
            warning.style.display = 'block';
        }
        
        // 打开服务端文件夹
        function openServerFolder() {
            // 调用后端API打开文件夹
            fetch('/open_folder')
                .then(response => response.json())
                .then(data => {
                    if(data.status === 'success') {
                        alert('服务端文件夹已打开: ' + data.path);
                    } else {
                        alert('打开文件夹失败: ' + data.message);
                    }
                });
        }
        
        // 初始化
        updateStepIndicator();
        
        // 页面加载完成后获取默认路径
        window.addEventListener('DOMContentLoaded', (event) => {
            // 获取默认安装路径
            fetch('/get_default_path')
                .then(response => response.json())
                .then(data => {
                    if(data.status === 'success') {
                        installPath = data.default_path;
                        document.getElementById('install-path').textContent = installPath;
                    } else {
                        // 使用硬编码的默认路径
                        installPath = "C:\\Users\\YourName\\Documents\\SurvivalWarServer";
                        document.getElementById('install-path').textContent = installPath;
                    }
                })
                .catch(error => {
                    // 使用硬编码的默认路径
                    installPath = "C:\\Users\\YourName\\Documents\\SurvivalWarServer";
                    document.getElementById('install-path').textContent = installPath;
                });
        });
    </script>
</body>
</html>